<template>
    <el-card>
        <div slot="header" class="clearfix">
        <span>
            物资记录
        </span>
    </div>
    
     <el-form  >
      
     </el-form>
        
    
    <div>
        <el-table :data="fillterAndPageData" style="width: 100%">
            <el-table-column prop="id" label="序号" width="150"></el-table-column>
            <el-table-column prop="assort" label="分类" width="150"></el-table-column>
            <el-table-column prop="mingcheng" label="名称" width="150"></el-table-column>
            <el-table-column prop="specs" label="规格" width="150"></el-table-column>
            <el-table-column prop="unity" label="单位" width="150"></el-table-column>
            <el-table-column prop="stock" label="现有库存" width="150"></el-table-column>
           
            <el-table-column label="操作">
                <template #header>
                 
                        <el-input v-model="searchValue" size="mini" style="width:220px" placeholder="输入关键字搜索" />
                    
                    
                        <el-button  size="mini" @click="queding">搜索</el-button>
                
                    </template>
                    <template slot-scope="scope">
                        <el-button size="mini" type="success" @click="buy(scope.row.assort,scope.row.mingcheng,scope.row.specs,scope.row.unity)">购买</el-button>
                        <el-button size="mini" type="primary" @click="share(scope.row.assort,scope.row.mingcheng)">分配</el-button>
                        
                    </template>
                    
                </el-table-column>
        </el-table>
        <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNumber"
      :page-sizes="[6,8,10]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next"
      :total="total">
    </el-pagination>
   
  
    </div>
    </el-card>
</template>
<script>
    export default{
        data(){
            return{
                fillterAndPageData:'',
                pageNumber:'',
                pageSize:'',
                total:'',
                searchValue:''
            }
        },
        created(){
         this.query() 
        },
        methods:{
           query(){
            fetch("http://1.15.134.100:9999/wuzi?pageNumber="+this.pageNumber+"&pageSize="+this.pageSize+"&search="+this.searchValue,{
                method:"GET",
                headers:{
                    'token': localStorage.getItem('token'),
                },
            })
            .then(res => res.json()).then(res =>{
                this.fillterAndPageData=res.data.list
                this.total=res.data.total

              

            })
           },
           handleSizeChange(pageSize) {
      this.pageSize=pageSize;
      this.query();
      },
      handleCurrentChange(pageNumber) {
       this.pageNumber=pageNumber;
       this.query();
      },
      buy(assort,mingcheng,specs,unity){
        this.$router.replace({
                  path:'/main/wuzi2',query:{assort:assort,mingcheng:mingcheng,specs:specs,unity:unity}
              })  
      },
      share(assort,mingcheng){
        this.$router.replace({
                  path:'/main/wuzi3',query:{assort:assort,mingcheng:mingcheng}
              })  
      },
      queding(){
        this.query()
      }
        }
    }
</script>

<style>
    .clearfix {
        display: flex;
       
    
    }
    
    .el-form{
        margin-bottom: 0px;
    }
    .el-pagination{
        margin-left: 800px;
        margin-top: 5px;
    }
    
 
    
    </style>